import { Component } from 'react';
import './Header.css'
class Header extends Component {
    // constructor(props) {
    //     super()
    //     console.log(props)
    // }
    setTodo = (e) => {
        // console.log(e.target.value)
        if(e.keyCode === 13) {
            this.props.fn(e.target.value)
            e.target.value = ''
        }
    }
    render() {
        return (
            <div id="header">
                <header>
                    <span>ToDoList</span>
                    <input placeholder="添加todo" onKeyUp={this.setTodo}/>
                </header>
            </div>
        )
    }
}
export default Header